﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using NHibernate.Audit.Cfg;
using NHibernate.Mapping;

namespace NHibernate.Audit.Contract.Cfg
{

    /// <summary>
    /// Contract for NHibernate.Audit.Cfg.IAuditTableConvention
    /// </summary>
    /// <remarks>
    /// Inherit this test fixture to prove an IAuditTableConvention implementation
    /// </remarks>
    public abstract class AuditTableConventionContract : AbstractContract<IAuditTableConvention>
    {
        protected override bool FixtureRequiresNHibernate()
        {
            return false;
        }

        protected override void Configure(NHibernate.Cfg.Configuration configuration)
        {
            // No mapping to load for these tests
        }


        [Test]
        public void audit_table_name_is_not_null_or_empty()
        {
            var tblConv = ServiceLocator.GetInstance<IAuditTableConvention>();
            var tbl = new Table("test");
            var auditTable = new Table();
            tbl.IsQuoted = true;
            Assert.IsNotNullOrEmpty(tblConv.GetAuditTableNameFor(tbl));
        }

        [Test]
        public void audit_table_name_is_different_than_table_name()
        {
            var tblConv = ServiceLocator.GetInstance<IAuditTableConvention>(); 
            var tbl = new Table("test");
            var auditTable = new Table();
            tbl.IsQuoted = true;
            auditTable.Name = tblConv.GetAuditTableNameFor(tbl);
            Assert.AreNotEqual(auditTable.Name, tbl.Name);
        }


    }
}
